<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-11-09 12:54:41
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: BOM成品工艺
 */

namespace App\Models;

use App\Traits\AutoCodeTrait;
use App\Traits\MaterialTrait;
use App\Traits\AttachmentTrait;

class ProColor extends BaseModel
    {
    use MaterialTrait;
    use AttachmentTrait;
    use AutoCodeTrait;
    public $timestamps = true;
    public $table = "basedata_pro_color";
    protected $guarded = [];

    public function company()
        {
        return $this->belongsTo(Company::class);
        }
    public function details()
        {
        return $this->hasMany(ProColorRev::class, "main_id");
        }
    public function ColorShade()
        {
        return $this->belongsTo(Dic::class, "ColorShade_id", "key")->where(function ($q)
            {
            $q->where("code", 'ColorShade');
            });
        }

    public function color_revision()
        {
        return $this->hasMany(ProColorMy::class, "color_id");
        }
    public function market()
        {
        return $this->hasMany(MarketOrderDetails::class, "color_id");
        }
    }
